﻿using System;
using System.Collections.Generic;
using YXYLCommon;

namespace Entity
{
    
    [Serializable]
    /// <summary>
    /// 报表参数
    /// </summary>
    public class BaoBiaoMBCS: BaseModel
    {
        public BaoBiaoMBCS()
        {
            this.ID = DbInt.InitNull();
            this.I_BAOBIAOID = DbInt.InitNull();
        }
        public DbInt ID { get; set; }
        
        /// <summary>
        /// 报表ID
        /// </summary>
        public DbInt I_BAOBIAOID { get; set; }

        /// <summary>
        /// 报表名称
        /// </summary>
        public string S_BAOBIAOMC { get; set; }

        /// <summary>
        /// 打印横向偏移量
        /// </summary>
        public DbInt I_X { get; set; }

        /// <summary>
        /// 打印纵向偏移量
        /// </summary>
        public DbInt I_Y { get; set; }

        /// <summary>
        /// 打印机名称
        /// </summary>
        public string S_PRINTERNAME { get; set; }

        /// <summary>
        /// 打印份数
        /// </summary>
        public DbInt I_COPIES { get; set; }

        /// <summary>
        /// 时间戳
        /// </summary>
        public string S_SHIJIANC { get; set; }

        /// <summary>
        /// 主机IP
        /// </summary>
        public string S_ZHUJIIP { get; set; }

        /// <summary>
        /// 主机名称
        /// </summary>
        public string S_ZHUJIMC { get; set; }

        public string S_BEIZHU1 { get; set; }

        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;
            this.ID = DbInt.Parse(row["ID"]);
            this.I_BAOBIAOID = DbInt.Parse(row["I_BAOBIAOID"]);
            this.S_BAOBIAOMC = Convert.ToString(row["S_BAOBIAOMC"]);
            this.I_X = DbInt.Parse(row["I_X"]);
            this.I_Y = DbInt.Parse(row["I_Y"]);
            this.S_PRINTERNAME = Convert.ToString(row["S_PRINTERNAME"]);
            this.I_COPIES = DbInt.Parse(row["I_COPIES"]);
            this.S_SHIJIANC = Convert.ToString(row["S_SHIJIANC"]);
            this.S_ZHUJIIP = Convert.ToString(row["S_ZHUJIIP"]);
            this.S_ZHUJIMC = Convert.ToString(row["S_ZHUJIMC"]);
            this.S_BEIZHU1 = Convert.ToString(row["S_BEIZHU1"]);
            return this;
        }
    }

    public class DALBaoBiaoMBCS:BaseDAL
    {
        public DALBaoBiaoMBCS()
        {
           
        }
        protected override void fillSaveProc(BaseModel model)
        {
            
        }

        /// <summary>
        /// 根据报表及当前登录人加载打印配置
        /// 如无对应登录人保存的配置,则取该报表默认配置(zhujiip=0)
        /// </summary>
        /// <param name="baobiaoid">报表ID</param>
        /// <param name="zhujiip">主机IP(传入登录人)</param>
        public BaoBiaoMBCS GetByBaoBiaoAndZhuJi(int baobiaoid,string zhujimc,string zhujiip)
        {
            dbProc.Init("P_YSBBMBCS_GET");
            dbProc.AddParameter("V_I_BAOBIAOID", baobiaoid);
            dbProc.AddParameter("V_S_ZHUJIMC", zhujimc);
            dbProc.AddParameter("V_S_ZHUJIIP", zhujiip);
            dbProc.AddOracleCursor();
            return CommonService.Ini().GetObject<BaoBiaoMBCS>(dbProc);
        }    

        /// <summary>
        /// 保存
        /// </summary>
        public DbCmdResult Save(BaoBiaoMBCS obj)
        {
            dbProc.Init("P_YSBBMBCS_SAVE");
            dbProc.AddParameter("V_ID", obj.ID.DvalueDBParameter);
            dbProc.AddParameter("V_I_BAOBIAOID", obj.I_BAOBIAOID.DvalueDBParameter);
            dbProc.AddParameter("V_S_BAOBIAOMC", obj.S_BAOBIAOMC);
            dbProc.AddParameter("V_I_X", obj.I_X.DvalueDBParameter);
            dbProc.AddParameter("V_I_Y", obj.I_Y.DvalueDBParameter);
            dbProc.AddParameter("V_S_PRINTERNAME", obj.S_PRINTERNAME);
            dbProc.AddParameter("V_I_COPIES", obj.I_COPIES.DvalueDBParameter);
            dbProc.AddParameter("V_S_SHIJIANC", obj.S_SHIJIANC);
            dbProc.AddParameter("V_S_ZHUJIIP", obj.S_ZHUJIIP);
            dbProc.AddParameter("V_S_ZHUJIMC", obj.S_ZHUJIMC);
            dbProc.AddParameter("V_OPERATE", obj.Operate.ToString());
            return CommonService.Ini().ExcuteProcOracle(dbProc);
        }
    }
    
}